<?php
    /******************************************************************************
     *    Copyright ZhangYue
     * Author:                Quinn Xu
     * Description:           
     * Want argument:         
     * Output:                
     * Create Date:           2012-12-28
     *****************************************************************************/
    class jiaoshiguanli
    {
        private $shujubiao='jiaoshi';
        
        public function huoqujiaoshiliebiao()
        {
            global $db;
            $query = "SELECT * FROM {$this->shujubiao} ORDER BY banji,id ASC";
            $result =$db->query($query);
			return $result;
        }

		//更改教师表记录
		public function genggaijiaoshixinxi($model)
		{
			global $db;
			$query = "UPDATE {$this->shujubiao} SET banji='{$model->getBanji()}',kemu='{$model->getKemu()}',xingming='{$model->getXingming()}',miaoshu='{$model->getMiaoshu()}' WHERE id='{$model->getId()}'";
			$db->execute($query);
			file_put_contents('D:/log.txt',$query."\r\n",FILE_APPEND);
			return $db->affected_rows();
		}
		

		//教师表记录添加
		public function tianjiajiaoshixinxi($model)
		{
			global $db;
			$query = "INSERT INTO {$this->shujubiao} (banji,kemu,xingming,miaoshu) VALUES ('{$model->getBanji()}','{$model->getKemu()}','{$model->getXingming()}','{$model->getMiaoshu()}')";
			$db->execute($query);
			return $db->affected_rows();
		}

		//删除教师表记录
		public function shanchujilu($model)
		{
			global $db;
			$query = "DELETE FROM {$this->shujubiao} WHERE id='{$model->getId()}'";
			$db->execute($query);
			return $db->affected_rows();
		}

    }
?>